home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / gfx / nsDeviceContext.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  6KB  |  173 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *   Roland Mainz <Roland.Mainz@informatik.med.uni-giessen.de>
  24.  *
  25.  * Alternatively, the contents of this file may be used under the terms of
  26.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  27.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.  * in which case the provisions of the GPL or the LGPL are applicable instead
  29.  * of those above. If you wish to allow use of your version of this file only
  30.  * under the terms of either the GPL or the LGPL, and not to allow others to
  31.  * use your version of this file under the terms of the MPL, indicate your
  32.  * decision by deleting the provisions above and replace them with the notice
  33.  * and other provisions required by the GPL or the LGPL. If you do not delete
  34.  * the provisions above, a recipient may use your version of this file under
  35.  * the terms of any one of the MPL, the GPL or the LGPL.
  36.  *
  37.  * ***** END LICENSE BLOCK ***** */
  38.  
  39. #ifndef nsDeviceContext_h___
  40. #define nsDeviceContext_h___
  41.  
  42. #include "nsIDeviceContext.h"
  43. #include "nsIDeviceContextSpec.h"
  44. #include "nsCOMPtr.h"
  45. #include "nsIAtom.h"
  46. #include "nsVoidArray.h"
  47. #include "nsIObserver.h"
  48. #include "nsIObserverService.h"
  49. #include "nsWeakReference.h"
  50. #include "gfxCore.h"
  51.  
  52. class nsIImageRequest;
  53. class nsHashtable;
  54.  
  55. class NS_GFX nsFontCache
  56. {
  57. public:
  58.   nsFontCache();
  59.   virtual ~nsFontCache();
  60.  
  61.   virtual nsresult Init(nsIDeviceContext* aContext);
  62.   virtual nsresult GetDeviceContext(nsIDeviceContext *&aContext) const;
  63.   virtual nsresult GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup,
  64.                                  nsIFontMetrics *&aMetrics);
  65.  
  66.   nsresult   FontMetricsDeleted(const nsIFontMetrics* aFontMetrics);
  67.   nsresult   Compact();
  68.   nsresult   Flush();
  69.   /* printer device context classes may create their own
  70.    * subclasses of nsFontCache (and override this method) and override 
  71.    * DeviceContextImpl::CreateFontCache (see bug 81311).
  72.    */
  73.   virtual nsresult CreateFontMetricsInstance(nsIFontMetrics** fm);
  74.   
  75. protected:
  76.   nsVoidArray      mFontMetrics;
  77.   nsIDeviceContext *mContext; // we do not addref this since
  78.                               // ownership is implied. MMP.
  79. };
  80.  
  81. #undef  IMETHOD_VISIBILITY
  82. #define IMETHOD_VISIBILITY NS_VISIBILITY_DEFAULT
  83.  
  84. class NS_GFX DeviceContextImpl : public nsIDeviceContext,
  85.                                  public nsIObserver,
  86.                                  public nsSupportsWeakReference
  87. {
  88. public:
  89.   DeviceContextImpl();
  90.  
  91.   NS_DECL_ISUPPORTS
  92.   NS_DECL_NSIOBSERVER
  93.  
  94.   NS_IMETHOD  Init(nsNativeWidget aWidget);
  95.  
  96.   NS_IMETHOD  CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext);
  97.   NS_IMETHOD  CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext);
  98.   NS_IMETHOD  CreateRenderingContext(nsIRenderingContext *&aContext){return NS_ERROR_NOT_IMPLEMENTED;}
  99.   NS_IMETHOD  CreateRenderingContext(nsIDrawingSurface* aSurface, nsIRenderingContext *&aContext);
  100.   NS_IMETHOD  CreateRenderingContextInstance(nsIRenderingContext *&aContext);
  101.  
  102.   NS_IMETHOD  GetCanonicalPixelScale(float &aScale) const;
  103.   NS_IMETHOD  SetCanonicalPixelScale(float aScale);
  104.  
  105.   NS_IMETHOD  GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup,
  106.                             nsIFontMetrics*& aMetrics);
  107.   NS_IMETHOD  GetMetricsFor(const nsFont& aFont, nsIFontMetrics*& aMetrics);
  108.  
  109.   NS_IMETHOD  SetZoom(float aZoom);
  110.   NS_IMETHOD  GetZoom(float &aZoom) const;
  111.  
  112.   NS_IMETHOD FirstExistingFont(const nsFont& aFont, nsString& aFaceName);
  113.  
  114.   NS_IMETHOD GetLocalFontName(const nsString& aFaceName, nsString& aLocalName,
  115.                               PRBool& aAliased);
  116.  
  117.   NS_IMETHOD CreateFontCache();
  118.   NS_IMETHOD FontMetricsDeleted(const nsIFontMetrics* aFontMetrics);
  119.   NS_IMETHOD FlushFontCache(void);
  120.  
  121.   NS_IMETHOD GetDepth(PRUint32& aDepth);
  122.  
  123.   NS_IMETHOD GetPaletteInfo(nsPaletteInfo& aPaletteInfo);
  124.  
  125.   NS_IMETHOD PrepareDocument(PRUnichar * aTitle, 
  126.                              PRUnichar*  aPrintToFileName) { return NS_OK; }
  127.   NS_IMETHOD AbortDocument(void) { return NS_OK; }
  128.  
  129. #ifdef NS_PRINT_PREVIEW
  130.   NS_IMETHOD SetAltDevice(nsIDeviceContext* aAltDC);
  131.   NS_IMETHOD GetAltDevice(nsIDeviceContext** aAltDC) { *aAltDC = mAltDC.get(); NS_IF_ADDREF(*aAltDC); return NS_OK;}
  132.   NS_IMETHOD SetUseAltDC(PRUint8 aValue, PRBool aOn);
  133. #endif
  134.  
  135. private:
  136.   /* Helper methods for |CreateRenderingContext|&co. */
  137.   nsresult InitRenderingContext(nsIRenderingContext *aContext, nsIWidget *aWindow);
  138.   nsresult InitRenderingContext(nsIRenderingContext *aContext, nsIDrawingSurface* aSurface);
  139.  
  140. protected:
  141.   virtual ~DeviceContextImpl();
  142.  
  143.   void CommonInit(void);
  144.   nsresult CreateIconILGroupContext();
  145.   virtual nsresult CreateFontAliasTable();
  146.   nsresult AliasFont(const nsString& aFont, 
  147.                      const nsString& aAlias, const nsString& aAltAlias,
  148.                      PRBool aForceAlias);
  149.   void GetLocaleLangGroup(void);
  150.  
  151.   nsFontCache       *mFontCache;
  152.   nsCOMPtr<nsIAtom> mLocaleLangGroup; // XXX temp fix for performance bug - erik
  153.   float             mZoom;
  154.   nsHashtable*      mFontAliasTable;
  155.   float             mCPixelScale;
  156.  
  157. #ifdef NS_PRINT_PREVIEW
  158.   nsCOMPtr<nsIDeviceContext> mAltDC;
  159.   PRUint8           mUseAltDC;
  160. #endif
  161.  
  162. public:
  163.   nsNativeWidget    mWidget;
  164. #ifdef NS_DEBUG
  165.   PRBool            mInitialized;
  166. #endif
  167. };
  168.  
  169. #undef  IMETHOD_VISIBILITY
  170. #define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
  171.  
  172. #endif /* nsDeviceContext_h___ */
  173.